Charger 24 Click
Charger 24 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Apr 2025.
- Type : GPIO type
Software Support
Example Description
This example demonstrates the use of the Charger 24 Click board. The application initializes the device, enables battery charging, and continuously monitors the charging and USB power status. It displays whether the battery is currently charging, fully charged, or if no input is detected, as well as whether the USB power is valid.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Charger24
Example Key Functions
- charger24_cfg_setup This function initializes Click configuration structure to initial values.
void charger24_cfg_setup(charger24_cfg_t *cfg)
Charger 24 configuration object setup function.
Charger 24 Click configuration object.
Definition charger24.h:120
- charger24_init This function initializes all necessary pins and peripherals used for this Click board.
err_t charger24_init(charger24_t *ctx, charger24_cfg_t *cfg)
Charger 24 initialization function.
Charger 24 Click context object.
Definition charger24.h:106
- charger24_enable_charging This function enables battery charging on the Charger 24 Click board.
void charger24_enable_charging(charger24_t *ctx)
Charger 24 enable charging function.
- charger24_get_iok_pin This function returns the logic state of the IOK pin.
uint8_t charger24_get_iok_pin(charger24_t *ctx)
Charger 24 get IOK pin function.
- charger24_get_status This function checks the battery charging status by polling the STAT pin.
uint8_t charger24_get_status(charger24_t *ctx)
Charger 24 get status function.
Application Init
Initializes the logger and the Charger 24 Click driver and enables charging while disabling boost mode.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( DIGITAL_OUT_UNSUPPORTED_PIN ==
charger24_init( &charger24, &charger24_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define CHARGER24_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition charger24.h:92
void charger24_disable_boost(charger24_t *ctx)
Charger 24 disable boost function.
void application_init(void)
Definition main.c:39
#define MIKROBUS_POSITION_CHARGER24
Definition main.c:33
Application Task
Periodically reads and logs the charging and USB power status.
{
log_printf( &logger, "\r\n Charging status: " );
switch ( status )
{
{
log_printf( &logger, "No input or fault\r\n" );
break;
}
{
log_printf( &logger, "Trickle, precharge, fast charge\r\n" );
break;
}
{
log_printf( &logger, "Top-off and done\r\n" );
break;
}
default:
{
log_printf( &logger, "Unknown\r\n" );
break;
}
}
log_printf( &logger, " USB status: " );
{
log_printf( &logger, "No power\r\n" );
}
else
{
log_printf( &logger, "Power good\r\n" );
}
}
#define CHARGER24_STATE_CHARGING
Definition charger24.h:73
#define CHARGER24_STATE_NO_INPUT
Charger 24 charging state setting.
Definition charger24.h:72
#define CHARGER24_STATE_CHARGE_DONE
Definition charger24.h:74
void application_task(void)
Definition main.c:72
Note
Ensure a valid USB input source and battery are connected to observe status transitions.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.